<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/common.css"/>
    <link rel="stylesheet" href="css/main.css"/>
    <link rel="stylesheet" href="css/jquery-ui-timepicker-addon.css"/>
    <link rel="stylesheet" href="css/jquery-ui.css"/>
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="css/city-picker.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/jquery-impromptu.min.css" type="text/css"/>
    <title>历史报销数据信息</title>

</head>
<body>
    <div id="dataLoad" style="display:none; position: fixed; width: 100%; top: 20%; z-index: 1001;">
           <table width=100% height=100% border=0 align=center valign=middle>
            <tr height=50%><td align=center>&nbsp;</td></tr>
            <tr><td align=center><img src="images/loading.gif"/></td></tr>
            <tr><td align=center>提交中，请稍后......</td></tr>
            <tr height=50%><td align=center>&nbsp;</td></tr>
           </table>  
    </div>
    <div class="container">
    <div id="forms" class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top">
                    <b class="pl15">报销人信息</b>
                    <input type="button" value="历史报销" id="history_info" class="ext_btn ext_btn_success" >
                </div>
                <div class="box_center">
                    <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="td_right">所属部门：</td>
                            <td class="">
                                <input type="text" placeholder="请输入所属部门" class="input-text lh25" size="20" id="baoxiao_depart" disabled>
                            </td>
                            <td class="td_right">姓名：</td>
                            <td class="">
                                <input type="text" placeholder="请输入人员姓名" class="input-text lh25" size="20" id="baoxiao_name" disabled>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div id="search_bar" class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">报销项目</b></div>
                <div id="table" class="">
                    <div class="box span10 oh">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table" id="xiangmu_table">
                            <tr>
                                <th class="td_center" style="width: 25%">序号</th>
                                <th class="td_center" style="width: 25%">项目名称</th>
                                <th class="td_center" style="width: 25%">项目类型</th>
                                <th class="td_center" style="width: 25%">填报金额</th>
                            </tr>
                            <tr class="fee_info">
                                <td class="td_right" colspan="3">合计金额</td>
                                <td class="td_center"><span id="total_fee">0</span></td>
                            </tr>
                        </table>
                    </div>
                </div>

            </div>
        </div>
    </div>
    <div class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">报销信息</b></div>
                <div class="box_center">
                    <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="td_right">现金报销：</td>
                            <td class="">
                                <input type="text" class="input-text lh25" size="20" id="cash_info" disabled>
                            </td>
                            <td class="td_right">公务卡报销：</td>
                            <td class="">
                                <input type="text" class="input-text lh25" size="20" id="official_info" disabled>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_right">转账金额：</td>
                            <td class="">
                                <input type="text" class="input-text lh25" size="20" id="trans_info" disabled>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">关联借款信息</b></div>
                <div class="box_center">
                    <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="td_right">借款单号：</td>
                            <td class="">
                                <input type="text" class="input-text lh25" size="20" id="pre_loan_id" disabled>
                            </td>
                            <td class="td_right">借款金额：</td>
                            <td class="">
                                <input type="text" class="input-text lh25" size="20" id="pre_loan_fee" disabled>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_right">应退金额：</td>
                            <td class="">
                                <input type="text" class="input-text lh25" size="20" id="back_fee" disabled>
                            </td>
                            <td class="td_right">应补金额：</td>
                            <td class=""><input type="text" class="input-text lh25" size="20" id="make_up_fee" disabled></td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="box_bottom pb5 pt5 pr10 print_area" style="border:1px solid #dadada;">
        <div class="search_bar_btn" style="text-align:right;">
            <input type="button" id="confirm_btn" name="button" class="btn1 btn82 btn_save2" value="打印">
        </div>
    </div>
        <div class="box_bottom pb5 pt5 pr10 modify_area" style="border:1px solid #dadada;">
            <div class="search_bar_btn" style="text-align:right;">
                <input type="button" id="modify_btn" name="button" class="btn1 btn82 btn_save2" value="修改">
            </div>
        </div>
    <div class="box_bottom pb5 pt5 pr10 approve_area" style="border:1px solid #dadada;">
        <div class="search_bar_btn" style="text-align:right;">
            <input type="button" id="approve_btn" name="button" class="btn1 btn82 btn_config" value="审批">
        </div>
    </div>
    <div class="box_bottom pb5 pt5 pr10 fuhe_area" style="border:1px solid #dadada;">
        <div class="search_bar_btn" style="text-align:right;">
            <input type="button" id="fuhe_refuse" name="button" class="btn1 btn82 btn_del" value="驳回">
            <input type="button" id="fuhe_btn" name="button" class="btn1 btn82 btn_count" value="复核">
        </div>
    </div>

    <div id="app_dialog" class="mt10" style="display:none" title="审批窗口">
        <div class="box">
            <div class="box_center">
                <table class="form_table pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="td_left">审批意见：
                    <span class="">
                        <div class="select_border">
                            <div class="select_containers ">
                                <select id="app_opinion" class="select">
                                    <option value="1">同意</option>
                                    <option value="0">驳回</option>
                                </select>
                            </div>
                        </div>
                    </span>
                        </td>
                    </tr>
                    <tr>
                        <td class="td_left">详细意见：</td>
                    </tr>
                    <tr>
                        <td class="">
                            <textarea name="" id="app_opinion_detail" cols="20" rows="30" placeholder="请填写具体审批意见" class="textarea">同意报销</textarea>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
        <div class="mt10" id="fuhe_dlg" style="display:none">
            <div class="box">
                <div class="box_border">
                    <div class="box_top"><b class="pl15">复核项目</b></div>
                    <div id="" class="">
                        <div class="box span10 oh">
                            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table" id="fuhe_table">
                                <tr>
                                    <th class="td_center" style="width: 15%">序号</th>
                                    <th class="td_center" style="width: 17.5%">项目名称</th>
                                    <th class="td_center" style="width: 17.5%">项目类型</th>
                                    <th class="td_center" style="width: 17.5%">填报金额</th>
                                    <th class="td_center" style="width: 15%">复核金额</th>
                                </tr>
                                <tr class="fee_info">
                                    <td class="td_right" colspan="4">预报金额</td>
                                    <td class="td_center"><span id="pre_total_fee">0</span></td>
                                </tr>
                                <tr class="fee_info">
                                    <td class="td_right" colspan="4">实报金额</td>
                                    <td class="td_center"><span id="fuhe_total_fee">0</span></td>
                                </tr>
                            </table>
                        </div>
                    </div>

                </div>
            </div>

        </div>

        <div class="main_center span10 pt10" id="opinion_area">
            <div class="box_top">
                <b class="pl15">项目报销审批信息：</b>
            </div>
            <div class="span33 fl pt10" >
                <div class="box pr5">
                    <div class="box_border" style="height: 230px">
                        <div class="box_top">
                            <b>部门审批意见</b>
                            <input class="ext_btn ext_btn_submit app_detail" type="submit" value="详情">
                        </div>
                        <div class="box_center opinion" id="section_opinion"><h1>待审批</h1></div>
                        <div class="box_center sign"><h3>签批人：<img id="section_sign"  width="100px" height="50px"></h3></div>
                    </div>
                </div>
            </div>
            <div class="span33 fl pt10">
                <div class="box pl5 pr5">
                    <div class="box_border" style="height: 230px">
                        <div class="box_top">
                            <b>分管领导意见</b>
                            <input class="ext_btn ext_btn_submit app_detail" type="submit" value="详情">
                        </div>
                        <div class="box_center opinion" id="section_leader_opinion"><h1>待审批</h1></div>
                        <div class="box_center sign"><h3>签批人：<img id="section_leader_sign"  width="100px" height="50px"></h3></div>
                    </div>
                </div>
            </div>
            <div class="span33 fl pt10">
                <div class="box pl5">
                    <div class="box_border" style="height: 230px">
                        <div class="box_top">
                            <b>局领导意见</b>
                            <input class="ext_btn ext_btn_submit app_detail" type="submit" value="详情">
                        </div>
                        <div class="box_center opinion" id="leader_opinion"><h1>待审批</h1></div>
                        <div class="box_center sign"><h3>签批人：<img id="leader_sign"  width="100px" height="50px"></h3></div>
                    </div>
                </div>
            </div>
        </div>
        <div id="confirm_fee_dlg" class="mt10" style="display: none" title="报销金额复核">
            <div class="box">
                <div class="box_border">
                    <div class="box_center"></div>
                    <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="td_center" valign="top">现金报账：</td>
                            <td class="">
                                <input type="number" value="0" name="name" class="input-text lh25" size="10" id="cash_amonut">
                                <span></span>
                            </td>
                            <td class="td_center" valign="top">预报现金：</td>
                            <td class="">
                                <input type="number" value="0" name="name" class="input-text lh25" size="10" id="pre_cash" disabled>
                                <span></span>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_center" valign="top">公务卡报账：</td>
                            <td class="">
                                <input type="number" value="0" name="name" class="input-text lh25" size="10" id="official_amount">
                                <span></span>
                            </td>
                            <td class="td_center" valign="top">预报公务卡：</td>
                            <td class="">
                                <input type="number" value="0" name="name" class="input-text lh25" size="10" id="pre_official" disabled>
                                <span></span>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_center" valign="top">转账金额：</td>
                            <td class="">
                                <input type="number" value="0" name="name" class="input-text lh25" size="10" id="transform_amount">
                                <span></span>
                            </td>
                            <td class="td_center" valign="top">预报转账：</td>
                            <td class="">
                                <input type="number" value="0" name="name" class="input-text lh25" size="10" id="pre_transform" disabled>
                                <span></span>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_center" valign="top">当前总额：</td>
                            <td class="">
                                <input type="number" value="0" name="name" class="input-text lh25" size="10" id="total_final_amount" disabled>
                                <span></span>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_center" valign="top">复核总额：</td>
                            <td class="">
                                <input type="number" value="0" name="name" class="input-text lh25" size="10" id="pre_fuhe_final" disabled>
                                <span></span>
                            </td>
                            <td class="td_center" valign="top">预报总额：</td>
                            <td class="">
                                <input type="number" name="name" class="input-text lh25" size="10" id="pre_final_amount" disabled>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        </div>
</body>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/baoxiao.js"></script>
<script type="text/javascript" src="js/jquery-impromptu.min.js"></script>
<script type="text/javascript" src="js/jquery.slides.js" charset="gbk"></script>


<script type="text/javascript">
    //用于保存选择的项目的数组
    var xiangmu={data:[]};
    //用于保存复核的数据
    var fuhe = {};
    //存放当前项目数据
    var baoxiao  = {};

    var final_input = true;


    var approveOpinion = {};
    //辅助函数，用于默认用户数据
    function defultData(){
        //var baoxiao=JSON.parse(window.localStorage.getItem('baoxiao'));
        //console.log(JSON.stringify(baoxiao));
        $('#baoxiao_depart').val(baoxiao.data.section_name);
        $('#baoxiao_name').val(baoxiao.data.user_name);

        xiangmu.user_id = baoxiao.data.write_id;
        xiangmu.section_id = baoxiao.data.section_id;
        xiangmu.total_money = baoxiao.data.pre_total_fee;
        xiangmu.app_id = baoxiao.data.fee_id;

        $('#pre_loan_id').val(baoxiao.data.loan_fee_id == '' ? '无' : baoxiao.data.loan_fee_id);
        $('#pre_loan_fee').val(baoxiao.data.loan_fee);
        var back_fee = baoxiao.data.loan_fee - baoxiao.data.pre_total_fee;
        $('#back_fee').val(back_fee <= 0 ? 0 : back_fee.toFixed(2));
        var return_fee = -back_fee;
        $('#make_up_fee').val(return_fee <= 0 ? 0 : return_fee.toFixed(2));

        //是否显示历史报销按钮

        if(baoxiao.data.history_fee_id == ''){
            $('#history_info').hide();
        }
        else{
            $('#history_info').show();
        }


        //获取项目数据
        var freeD=baoxiao.data.data;
        //添加项目
        for(var i=0;i<freeD.length;i++){
            $('#xiangmu_table').find('tr').last().before(
                    "<tr class='tr user_tr'>" +
                        "<td class='td_center'>"+(i+1)+"</td>" +
                        "<td class='td_center'>"+freeD[i]['fee_item']+"</td>" +
                        "<td class='td_center'>"+freeD[i]['fee_type_name']+"</td>" +
                        "<td class='td_center'>"+freeD[i]['money']+"</td>" +
                    "</tr>");
            xiangmu.data.push({
                'fee_item_id' : freeD[i]['fee_item_id'],
                'fee_item' : freeD[i]['fee_item'],
                'fee_type' : freeD[i]['fee_type'],
                'money' : freeD[i]['money'],
                'fee_type_text' : freeD[i]['fee_type_name']
            });
        }
        $('#total_fee').text(xiangmu.total_money);

        //初始化关联报销信息

        $('#cash_info').val(baoxiao.data.cash);
        $('#trans_info').val(baoxiao.data.trans);
        $('#official_info').val(baoxiao.data.official);

        var v = parseInt(window.localStorage.getItem('is_history'));
        if(v == 1){
            $(".approve_area").hide();
            $(".fuhe_area").hide();
            $(".print_area").hide();
            $(".modify_area").hide();
        }
        else{
            var appType = window.localStorage.getItem('approve_state');
            switch(appType){
                case '0':  //我的报销点进来
                    $(".approve_area").hide();
                    $(".fuhe_area").hide();
                    if(baoxiao.data.state == 2){
                        $(".print_area").hide();
                        $(".modify_area").show();
                    }
                    else{
                        $(".print_area").show();
                        $(".modify_area").hide();
                    }
                    break;
                case '1': //部门审批，分管审批，领导审批点进来
                    $(".print_area").hide();
                    $(".approve_area").show();
                    $(".fuhe_area").hide();
                    $(".modify_area").hide();
                    break;
                case '4': //财务审批点进来
                    $(".print_area").hide();
                    $(".approve_area").hide();
                    $(".modify_area").hide();
                    $(".fuhe_area").show();
                    initFuheTable();
                    break;

            }
        }

    }

    //辅助函数，初始化最终复核对话框
    function initFinalFuheDlg(){

        $('#pre_cash').val(baoxiao.data.cash);
        $('#pre_official').val(baoxiao.data.official);
        $('#pre_transform').val(baoxiao.data.trans);
        $('#pre_fuhe_final').val(fuhe.fuhe_total_fee);
        $('#pre_final_amount').val(baoxiao.data.pre_total_fee)
    }

    //辅助函数，显示最终复核对话框
    function showFinalFuheDlg(){
        initFinalFuheDlg();
        $('#confirm_fee_dlg').dialog({
            resizable: false,
            height: "auto",
            width: "auto",
            modal: true,
            buttons: {
                '确定' : function(){
                    var r = getFinalFuheData();
                    if(r == -2){
                        $.prompt("<h3>数据输入有误，请修改</h3>", {
                            title: '错误提醒',
                            buttons: {'确定': true}
                        });
                    }
                    else if(r == -1){
                        $.prompt("<h3>金额大于复核总金额，请修改</h3>", {
                            title: '错误提醒',
                            buttons: {'确定': true}
                        });
                    }
                    else{
                        $(this).dialog('close');
                        $.prompt( "<h3>确定复核报销数据了吗？</h3>",{
                            title: '消息提醒',
                            buttons: {'确定': true},
                            submit: function(e, v, m ,f){
                                if(v) {
                                    //点击复核按钮
                                    $('#fuhe_dlg').dialog('close');
                                    fuheOrdinaryFee();
                                }
                            }
                        });

                    }
                },
                '取消':function(){
                    $(this).dialog('close');
                }
            }
        })
    }

    //辅助函数，处理最终复核对话框数据
    function getFinalFuheData(){
        if(!final_input){
            return -2;
        }
        var cash = parseFloat($('#cash_amonut').val());
        var official = parseFloat($('#official_amount').val());
        var trans = parseFloat($('#transform_amount').val());

        if( (cash + official + trans) != fuhe.fuhe_total_fee){
            return -1;
        }

        fuhe.cash = cash;
        fuhe.offical = official;
        fuhe.trans = trans;


        return 1;
    }

    //辅助函数，初始化复核对话框
    function initFuheTable(){

        //获取项目数据
        var freeD=baoxiao.data.data;
        //添加项目
        for(var i=0;i<freeD.length;i++) {
            $('#fuhe_table').find('.fee_info').first().before(
                    "<tr class='tr user_tr'>" +
                    "<td class='td_center'>" + (i + 1) + "</td>" +
                    "<td class='td_center'>" + freeD[i]['fee_item'] + "</td>" +
                    "<td class='td_center'>" + freeD[i]['fee_type_name'] + "</td>" +
                    "<td class='td_center'>" + freeD[i]['money'] + "</td>" +
                    "<td class='td_center'><input type='number' size='10' class='input-text lh25 fuhe_input' placeholder='填写金额' value=0></td>" +
                    "</tr>");
        }
        //初始化借款信息
        $('#pre_loan_id2').val(baoxiao.data.loan_fee_id == '' ? '无' : baoxiao.data.loan_fee_id);
        $('#pre_loan_fee2').val(baoxiao.data.loan_fee);
        var back_fee = baoxiao.data.loan_fee - baoxiao.data.pre_total_fee;
        $('#back_fee2').val(back_fee <= 0 ? 0 : back_fee.toFixed(2));
        var return_fee = -back_fee;
        $('#make_up_fee2').val(return_fee <= 0 ? 0 : return_fee.toFixed(2));

        $('#pre_total_fee').text(baoxiao.data.pre_total_fee);


    }



    //辅助函数，处理基本报销信息审批
    function approveOrdinaryFee(){
        $('#approve_btn').click(function(){
            $('#app_dialog').dialog({
                resizable: false,
                height: "auto",
                width: 430,
                modal: true,
                title: '业务报销费用审批',
                buttons: {
                    '确定' :function(){
                        if($('#app_opinion_detail').val() == ""){
                            $.prompt("<h3>未填写审批意见，请填写</h3>", {
                                title: '错误提醒',
                                buttons: {'确定': true}
                            })
                        }
                        else{
                            approveOpinion.ordinay_fee_opinion = {
                                'basic_fee_opinion' : $('#app_opinion').val(),
                                'basic_fee_opinion_detail' : $('#app_opinion_detail').val(),
                            };

                            ApproveCurItem();
                            $(this).dialog("close");
                        }
                    },
                    '取消': function(){
                        $(this).dialog("close");
                    }
                }
            });
        })
    }

    //辅助函数，审批项目报销信息
    function ApproveCurItem(){
        $('#dataLoad').show();
        var userInfo = JSON.parse(window.localStorage.getItem('user_info'));
        var identity = window.localStorage.getItem('approve_type');
        approveOpinion.userID = userInfo.user_id;
        approveOpinion.approve_state = identity;
        approveOpinion.approve_id = baoxiao.data.fee_id;

        $.post(url+'OrdinaryFee/ApproveOrdinaryFee.php', approveOpinion, function(data){
            $('#dataLoad').hide();
            var t = JSON.parse(data);
            if(t.state == 1){
                $.prompt( "<h3>操作成功</h3>",{
                    title: '消息提醒',
                    buttons: {'确定': true},
                    submit: function(e, v, m ,f){
                        if(v)
                            jumpPage('section_approve.html');
                    }
                });
            }
            else{
                $.prompt( "<h3>网络或数据库错误，请稍后再试</h3>",{
                    title: '消息提醒',
                    buttons: {'确定': true}
                });
            }
        })

    }


    //辅助函数，处理复核金额数据输入
    function processFuheInput(){
        $('.fuhe_input').bind('input propertychange', function(){
            var fuhe_inputs = $('.fuhe_input');
            var fuhe_total_fee = 0.0;
            for(var i = 0; i < fuhe_inputs.length; i++ ){
                fuhe_total_fee += parseFloat($(fuhe_inputs[i]).val());
            }
            $('#fuhe_total_fee').text(parseFloat(fuhe_total_fee).toFixed(2));

            var baoxiao=JSON.parse(window.localStorage.getItem('baoxiao'));

            var back_fee = baoxiao.data.loan_fee - fuhe_total_fee;
            $('#back_fee2').val(back_fee <= 0 ? 0 : back_fee.toFixed(2));
            var return_fee = -back_fee;
            $('#make_up_fee2').val(return_fee <= 0 ? 0 : return_fee.toFixed(2));


        });
    }

    //辅助函数，处理复核信息的确认
    function confirmFuhe(){

        var user_info = JSON.parse(window.localStorage.getItem('user_info'));
        fuhe.user_id = user_info.user_id;
        fuhe.app_id = baoxiao.data.fee_id;
        fuhe.loan_fee_id = baoxiao.data.loan_fee_id;
        fuhe.fuhe_total_fee = $('#fuhe_total_fee').text();

        fuhe.fuhe_detail = baoxiao.data.data;

        $('.fuhe_input').each(function(){
            var id = $(this).parent().parent().find('td').eq(0).text();
            fuhe.fuhe_detail[id - 1].fuhe_money = $(this).val();
        });

    }

    //辅助函数，上传复核数据
    function fuheOrdinaryFee(){

        $('#dataLoad').show();
        $.post(url + 'OrdinaryFee/FinanceOrdinaryFeeApprove.php', fuhe, function(data){
            $('#dataLoad').hide();
            var t = JSON.parse(data);
            if(t.state == 1){
                $.prompt( "<h3>操作成功</h3>",{
                    title: '消息提醒',
                    buttons: {'确定': true},
                    submit: function(e, v, m ,f){
                        if(v){
                            printOrdinaryFeePDF();
                        }
                    }
                });
            }
            else{
                $.prompt( "<h3>网络或数据库繁忙，请稍后再试</h3>",{
                    title: '消息提醒',
                    buttons: {'确定': true}
                });
            }
        })
    }

    //辅助函数，打印报销单数据
    //辅助函数，复核成功后的PDF打印功能
    function printOrdinaryFeePDF(){
        $.prompt("<h3>自动生成报销单</h3>", {
            title: '操作提醒',
            buttons: {'确定': true},
            submit: function (e, v, m, f) {
                if(v){
                    $('#dataLoad').show();
                    $.post(url + 'PDF/CreateOrdinaryFeePDF.php', {'approval_id':fuhe.app_id}, function(data){
                        var t= JSON.parse(data);
                        $('#dataLoad').hide();
                        if(t.state == 1){
                            window.open(url + t.url);
                            jumpPage('finance_fee_approve.html');
                        }
                        else{
                            $.prompt("<h3>生成失败，请稍后在打印报销单功能中尝试</h3>", {
                                title: '错误提醒',
                                buttons: {'确定': true},
                                submit: function(e, v, m, f){
                                    if(v){
                                        jumpPage('finance_fee_approve.html');
                                    }
                                }
                            })
                        }
                    });
                }
            }
        });
    }

    //当点击修改按钮的时候
    function pressModify(){
        $('#modify_btn').click(function(){
            $.prompt("<h3>修改数据需要重新输入所有数据</h3>", {
                title: '操作提醒',
                buttons: {'确定': true},
                submit: function(e, v, m ,f){
                    if(v){
                        //window.localStorage.setItem('cur_travel_info', JSON.stringify(curItem.travel_app_data));
                        window.localStorage.setItem('history_ordinary_fee_id', baoxiao.data.fee_id);
                        jumpPage('baoxiao.html');
                        //把当前数据作为历史数据,且只是查看模式
                        window.localStorage.setItem('is_history', 1);
                        window.localStorage.setItem('historyBaoxiaoInfo', JSON.stringify(baoxiao));
                        window.open('baoxiao_info.html');
                    }

                }
            });
        })
    }

    //显示历史数据按钮
    function processHistoryInfo(){
        $('#history_info').click(function(){
            $('#dataLoad').show();

            $.post(url + 'OrdinaryFee/GetOrdinaryFeeDetail.php', {'appID' : baoxiao.data.history_fee_id}, function(data){
                $('#dataLoad').hide();
                var t = JSON.parse(data);
                if(t.state == 1){
                    window.localStorage.setItem('is_history', 1);
                    window.localStorage.setItem('historyBaoxiaoInfo', data);
                    window.open('baoxiao_info.html');
                }
                else{
                    $.prompt("<h3>服务器忙或网络故障，请稍后再试</h3>", {
                        title: '操作提醒',
                        buttons: {'确定': true}
                    });
                }
            })
        })
    }

    //辅助函数，财务驳回复核数据
    function financeRefuseApprove(){
        $('#dataLoad').show();
        $.post(url + 'OrdinaryFee/FinanceRefuseApprove.php', {'fee_id':baoxiao.data.fee_id}, function(data){
            $('#dataLoad').hide();
            var t = JSON.parse(data);
            if(t.state == 1){
                $.prompt( "<h3>操作成功</h3>",{
                    title: '消息提醒',
                    buttons: {'确定': true},
                    submit: function(e, v, m ,f){
                        if(v)
                            jumpPage('finance_fee_approve.html');
                    }
                });
            }
            else{
                $.prompt( "<h3>网络或数据库繁忙，请稍后再试</h3>",{
                    title: '消息提醒',
                    buttons: {'确定': true}
                });
            }
        })
    }

    //辅助函数，显示详细审批意见
    function ShowApproveDetail(){

        $('.app_detail').each(function(){
            $(this).unbind('click');
        });
        var app_details = $('.app_detail');
        $(app_details[0]).click(function(){
            $.prompt( "<p>" + (baoxiao.data.section_approve_opinion == '' ? '未审批' : baoxiao.data.section_approve_opinion) + "</p>",{
                title: '审批详细信息',
                buttons: {'确定': true}
            });
        })
        $(app_details[1]).click(function(){
            $.prompt( "<p>" + (baoxiao.data.section_leader_opinion == '' ? '未审批' : baoxiao.data.section_leader_opinion) + "</p>",{
                title: '审批详细信息',
                buttons: {'确定': true}
            });
        })
        $(app_details[2]).click(function(){
            $.prompt( "<p>" + (baoxiao.data.leader_opionion == '' ? '未审批' : baoxiao.data.leader_opionion) + "</p>",{
                title: '审批详细信息',
                buttons: {'确定': true}
            });
        })

    }

    $(function(){
        //设置审批状态
       // setApproveState();
        //判断历史信息
        var v = window.localStorage.getItem('is_history');


        if(v == 1){
            //如果是非历史信息，curItem为当前信息，否则为历史信息
            baoxiao = JSON.parse(window.localStorage.getItem('historyBaoxiaoInfo'));
        }
        else{
            baoxiao = JSON.parse(window.localStorage.getItem('baoxiao'));
        }

        //设置默认用户
        defultData();

        setApproveOpinion(baoxiao.data, 4);
        approveOrdinaryFee();

        pressModify();
        processHistoryInfo();

        ShowApproveDetail();

        $('#app_opinion').change(function(){
            if($(this).val() == 1){
                $('#app_opinion_detail').val('同意报销');
            }
            else{
                $('#app_opinion_detail').val('');
            }
        });

        processFuheInput();

        processFinalInput();
        processFinalCheckFee();

        $('#fuhe_refuse').click(function(e){
            $.prompt( "<h3>确定驳回本报销单吗？</h3>",{
                title: '消息提醒',
                buttons: {'确定': true, '取消':false},
                submit: function(e, v, m ,f){
                    if(v) {
                        //点击复核驳回按钮
                        financeRefuseApprove();
                    }
                }
            });
        });

        $('#fuhe_btn').click(function(e){
            initFinalFuheDlg();

            $('#fuhe_dlg').dialog({
                resizable: false,
                height: "auto",
                width: "auto",
                modal: true,
                title: '业务报销复核窗口',
                buttons:{
                    '确定': function(){
                        $(this).dialog('close');
                        confirmFuhe();
                        showFinalFuheDlg();

                    },
                    '取消': function(){
                        $('#fuhe_dlg').dialog('close');
                    }
                }
            })
        })

    });

</script>
</html>
  